{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# DICE Analysis Tutorial:\n",
    "In this tutorial, we'll go over how to run the dice_correlation.py script. The purpose of the script is to allow for the calculation of the Dice Coefficient between ROIs of two different atlases. This script outputs a series of png and csv files containing the Dice Coefficients."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "First the relevant libraries must be imported. dice_correlation utilizes the nibabel, numpy, argpars, matplotlib, os, sys, and math libraries."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import nibabel as nb\n",
    "import numpy as np\n",
    "from argparse import ArgumentParser\n",
    "import matplotlib\n",
    "from matplotlib import pyplot as plt\n",
    "import os\n",
    "import sys\n",
    "from math import floor"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Next we have to specify the inputs. For the purpose of this jupyter notebook sys.argv is used to store the inputs, but when running the script in the terminal:\n",
    "\n",
    "python $<$path_to_script$>$/dice_correlation.py $<$input_dir$>$ $<$output_dir$>$ $<$atlas1$>$ $<$atlas2$>$ $<$atlas3$>$ ...\n",
    "    \n",
    "input_dir = The path to the dirctory containing the atlases you intend to analyze\n",
    "\n",
    "output_dir = The path for the directory where you intend to have the output files saved\n",
    "    \n",
    "atlases = All the atlases you intend to have analyzed, seperated by spaces. You must provide at least 2 atlases, with no upper limit. Atlases should be of the same voxel size."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "input_dir = '/Users/ross/Documents/neuroparc/atlases/label/Human'\n",
    "output_dir = '/Users/ross/Documents/neuroparc/atlases'\n",
    "atlases = ['AAL_space-MNI152NLin6_res-1x1x1.nii.gz','AICHAJoliot2015_space-MNI152NLin6_res-1x1x1.nii.gz']\n",
    "\n",
    "#Necessary for running this function in a jupyter notebook\n",
    "sys.argv = ['',input_dir, output_dir, atlases[0],atlases[1]]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now the dice_roi function needs to be defined, which is where the majority of the calculations are done. The Dice Coefficients are calculated by itterating through every combination of ROIs from both atlases and storing them in an ndarray. That array is then used to create a png heatmap and a csv (comma delimited) file of the results.\n",
    "\n",
    "If you wish to change the format of the png files, you are able to change any of the formating code after the comment \"Generate png of heatmap\" without compromising any of the calculations."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "def dice_roi(input_dir, output_dir, atlas1, atlas2):\n",
    "    \"\"\"Calculates the dice coefficient for every ROI combination from atlas1 and atlas2\n",
    "\n",
    "    Parameters\n",
    "    ----------\n",
    "    input_dir : str\n",
    "        Path to input directory\n",
    "    output_dir : str\n",
    "        Path to output directory\n",
    "    atlas1 : str\n",
    "        path to first atlas to compare\n",
    "    atlas2 : str\n",
    "        path to second atlas to compare\n",
    "    \"\"\"\n",
    "\n",
    "    #Create output name for png file\n",
    "    yname = atlas1.split('_space-')[0]\n",
    "    res=atlas1.split('space-MNI152NLin6_res-')[1]\n",
    "    res=res.split('.nii')[0]\n",
    "    xname = atlas2.split('_space-')[0]\n",
    "    \n",
    "    #Create name for the generate files\n",
    "    png_name=f\"DICE_{yname}_&_{xname}_res-{res}\"\n",
    "\n",
    "    at1 = nb.load(f'{input_dir}/{atlas1}')\n",
    "    at2 = nb.load(f'{input_dir}/{atlas2}')\n",
    "\n",
    "    atlas1 = at1.get_data()\n",
    "    atlas2 = at2.get_data()\n",
    "    \n",
    "    #Get ROI numerical values for both atlases\n",
    "    labs1 = np.unique(atlas1)\n",
    "    labs2 = np.unique(atlas2)\n",
    "    \n",
    "    #Create ndarray of zeros to contain Dice Coefficients\n",
    "    Dice = np.zeros((labs1.size, labs2.size))\n",
    "\n",
    "    max_y=len(labs1)-1\n",
    "    max_x=len(labs2)-1\n",
    "\n",
    "    #Itterate through the ROIs of each atlas and calculate the Dice Coefficient\n",
    "    for i in range(len(labs1)):\n",
    "        val1=labs1[i]\n",
    "        for j in range(len(labs2)):\n",
    "            val2=labs2[j]\n",
    "            #Calculate Dice Coefficient\n",
    "            dice = np.sum(atlas1[atlas2==val2]==val1)*2.0 / (np.sum(atlas1[atlas1==val1]==val1) + np.sum(atlas2[atlas2==val2]==val2))\n",
    "            \n",
    "            #Store in ndarray\n",
    "            Dice[int(i)][int(j)]=float(dice)\n",
    "\n",
    "            print(f'Dice coefficient for {yname} {i} of {max_y}, {xname} {j} of {max_x} = {dice}')\n",
    "            \n",
    "            #Check for false Dice Coefficients and return what ROIs caused the issue\n",
    "            if dice > 1 or dice < 0:\n",
    "                raise ValueError(f\"Dice coefficient is greater than 1 or less than 0 ({dice}) at atlas1: {val1}, atlas2: {val2}\")\n",
    "\n",
    "    #Save Dice map to csv file, comma delimited\n",
    "    np.savetxt(f'{output_dir}/{png_name}.csv', Dice, delimiter=\",\")\n",
    "    \n",
    "    #Generate png of heatmap\n",
    "    fig, ax = plt.subplots()\n",
    "    #Create the heatmap:\n",
    "    #cmap = color-scheme\n",
    "    #norm = whether to make the colorbar logarithmic\n",
    "    im = ax.imshow(Dice, cmap=\"gist_heat_r\", norm=matplotlib.colors.LogNorm())\n",
    "\n",
    "    #If there are more than 30 ROIs in an atlas, if so, then increase the step size for tick marks\n",
    "    #on the x and y axes\n",
    "    if len(labs1)<30:\n",
    "        step1=1\n",
    "    else:\n",
    "        step1=floor(len(labs1)/30)\n",
    "\n",
    "    if len(labs2)<30:\n",
    "        step2=1\n",
    "    else:\n",
    "        step2=floor(len(labs2)/30)\n",
    "\n",
    "    #Create tickmarks for axes\n",
    "    ax.set_xticks(np.arange(0,len(labs2), step=step2))\n",
    "    ax.set_yticks(np.arange(0,len(labs1), step=step1))\n",
    "\n",
    "    #Add the label values to the corresponding tickmarks\n",
    "    ax.set_xticklabels(labs2[0::step2])\n",
    "    ax.set_yticklabels(labs1[0::step1])\n",
    "    \n",
    "    #Label x and y axes\n",
    "    ax.set_ylabel(f'ROIs for {yname} atlas')\n",
    "    ax.set_xlabel(f'ROIs for {xname} atlas')\n",
    "    \n",
    "    #Set the fontsize of the tickmark labels, rotate the x-axis labels 90 degrees to prevent overlap\n",
    "    plt.setp(ax.get_xticklabels(), fontsize=6, rotation=90, ha=\"right\", rotation_mode=\"anchor\")\n",
    "    plt.setp(ax.get_yticklabels(), fontsize=6)\n",
    "\n",
    "    #Set title for the heatmap\n",
    "    ax.set_title(f'{yname} vs {xname}')\n",
    "    \n",
    "    # Try to counteract the lopsided amount of ROIs between atlases\n",
    "    # By changing the aspect ratio between the x and y axes of the graph\n",
    "    aspect_ratio=len(labs2)/len(labs1)\n",
    "    ax.set_aspect(aspect=aspect_ratio)\n",
    "\n",
    "    plt.colorbar(im, aspect=30)\n",
    "    fig.tight_layout()\n",
    "\n",
    "    plt.show()\n",
    "    #Save Dice map as a png file\n",
    "    plt.savefig(f'{output_dir}/{png_name}.png', dpi=1000)\n",
    "\n",
    "\n",
    "    return Dice, labs1, labs2\n",
    "    print('Done')\n",
    "    "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now the main segment of the progam is defined, the main function can be created. This function serves to organize the inputs and files provided by the user before feeding them into the dice_roi function."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Beginning Dice ...\n",
      "/Users/ross/Documents/neuroparc/atlases/label/Human\n",
      "['AAL_space-MNI152NLin6_res-1x1x1.nii.gz', 'AICHAJoliot2015_space-MNI152NLin6_res-1x1x1.nii.gz']\n",
      "/Users/ross/Documents/neuroparc/atlases\n",
      "Dice coefficient for AAL 0 of 116, AICHAJoliot2015 0 of 384 = 0.9557796459157021\n",
      "Dice coefficient for AAL 0 of 116, AICHAJoliot2015 1 of 384 = 1.0449002337964272e-06\n",
      "Dice coefficient for AAL 0 of 116, AICHAJoliot2015 2 of 384 = 6.270397297598107e-06\n",
      "Dice coefficient for AAL 0 of 116, AICHAJoliot2015 3 of 384 = 9.00926127709931e-05\n",
      "Dice coefficient for AAL 0 of 116, AICHAJoliot2015 4 of 384 = 0.0001332181558607206\n",
      "Dice coefficient for AAL 0 of 116, AICHAJoliot2015 5 of 384 = 2.055205251432591e-05\n",
      "Dice coefficient for AAL 0 of 116, AICHAJoliot2015 6 of 384 = 1.3932934863007031e-05\n",
      "Dice coefficient for AAL 0 of 116, AICHAJoliot2015 7 of 384 = 6.616521558803726e-06\n",
      "Dice coefficient for AAL 0 of 116, AICHAJoliot2015 8 of 384 = 9.084544214320061e-05\n",
      "Dice coefficient for AAL 0 of 116, AICHAJoliot2015 9 of 384 = 8.316909756483318e-05\n",
      "Dice coefficient for AAL 0 of 116, AICHAJoliot2015 10 of 384 = 2.9586339464957156e-05\n",
      "Dice coefficient for AAL 0 of 116, AICHAJoliot2015 11 of 384 = 1.2182084573948125e-05\n",
      "Dice coefficient for AAL 0 of 116, AICHAJoliot2015 12 of 384 = 2.3319341148561083e-05\n",
      "Dice coefficient for AAL 0 of 116, AICHAJoliot2015 13 of 384 = 3.966437674477591e-05\n",
      "Dice coefficient for AAL 0 of 116, AICHAJoliot2015 14 of 384 = 4.2477932800954846e-05\n",
      "Dice coefficient for AAL 0 of 116, AICHAJoliot2015 15 of 384 = 5.917696331324159e-05\n",
      "Dice coefficient for AAL 0 of 116, AICHAJoliot2015 16 of 384 = 5.913809702300559e-05\n",
      "Dice coefficient for AAL 0 of 116, AICHAJoliot2015 17 of 384 = 0.00017300414740022978\n",
      "Dice coefficient for AAL 0 of 116, AICHAJoliot2015 18 of 384 = 5.2566214719062305e-05\n",
      "Dice coefficient for AAL 0 of 116, AICHAJoliot2015 19 of 384 = 3.482355514022662e-07\n",
      "Dice coefficient for AAL 0 of 116, AICHAJoliot2015 20 of 384 = 6.614227446920389e-06\n",
      "Dice coefficient for AAL 0 of 116, AICHAJoliot2015 21 of 384 = 1.600797614811554e-05\n",
      "Dice coefficient for AAL 0 of 116, AICHAJoliot2015 22 of 384 = 5.464063429075674e-05\n",
      "Dice coefficient for AAL 0 of 116, AICHAJoliot2015 23 of 384 = 0.0\n",
      "Dice coefficient for AAL 0 of 116, AICHAJoliot2015 24 of 384 = 9.402058667801414e-06\n",
      "Dice coefficient for AAL 0 of 116, AICHAJoliot2015 25 of 384 = 1.1140015195676979e-05\n",
      "Dice coefficient for AAL 0 of 116, AICHAJoliot2015 26 of 384 = 3.0986403409897024e-05\n",
      "Dice coefficient for AAL 0 of 116, AICHAJoliot2015 27 of 384 = 4.527232434904056e-06\n",
      "Dice coefficient for AAL 0 of 116, AICHAJoliot2015 28 of 384 = 3.724797351007671e-05\n",
      "Dice coefficient for AAL 0 of 116, AICHAJoliot2015 29 of 384 = 2.7498619412667777e-05\n",
      "Dice coefficient for AAL 0 of 116, AICHAJoliot2015 30 of 384 = 1.8456252847878168e-05\n",
      "Dice coefficient for AAL 0 of 116, AICHAJoliot2015 31 of 384 = 7.060880617030532e-05\n",
      "Dice coefficient for AAL 0 of 116, AICHAJoliot2015 32 of 384 = 0.00010156226766979116\n",
      "Dice coefficient for AAL 0 of 116, AICHAJoliot2015 33 of 384 = 2.2951033448523178e-05\n",
      "Dice coefficient for AAL 0 of 116, AICHAJoliot2015 34 of 384 = 2.783190019341431e-06\n",
      "Dice coefficient for AAL 0 of 116, AICHAJoliot2015 35 of 384 = 6.301755561168722e-05\n"
     ]
    },
    {
     "ename": "KeyboardInterrupt",
     "evalue": "",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mKeyboardInterrupt\u001b[0m                         Traceback (most recent call last)",
      "\u001b[0;32m<ipython-input-4-89c90d2d7744>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m     47\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     48\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0m__name__\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0;34m\"__main__\"\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 49\u001b[0;31m     \u001b[0mmain\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[0;32m<ipython-input-4-89c90d2d7744>\u001b[0m in \u001b[0;36mmain\u001b[0;34m()\u001b[0m\n\u001b[1;32m     44\u001b[0m         \u001b[0;32mfor\u001b[0m \u001b[0mj\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mrange\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mlen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0matlases\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     45\u001b[0m             \u001b[0;32mif\u001b[0m \u001b[0mj\u001b[0m \u001b[0;34m>\u001b[0m \u001b[0mi\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 46\u001b[0;31m                 \u001b[0mDice_matrix\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mylabels\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mxlabels\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mdice_roi\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0minput_dir\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0moutput_dir\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0matlases\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mi\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0matlases\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mj\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m     47\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     48\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0m__name__\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0;34m\"__main__\"\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m<ipython-input-3-1c71261fb8e2>\u001b[0m in \u001b[0;36mdice_roi\u001b[0;34m(input_dir, output_dir, atlas1, atlas2)\u001b[0m\n\u001b[1;32m     36\u001b[0m         \u001b[0;32mfor\u001b[0m \u001b[0mj\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mrange\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mlen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mlabs2\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     37\u001b[0m             \u001b[0mval2\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mlabs2\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mj\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 38\u001b[0;31m             \u001b[0mdice\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msum\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0matlas1\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0matlas2\u001b[0m\u001b[0;34m==\u001b[0m\u001b[0mval2\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m==\u001b[0m\u001b[0mval1\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0;36m2.0\u001b[0m \u001b[0;34m/\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msum\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0matlas1\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0matlas1\u001b[0m\u001b[0;34m==\u001b[0m\u001b[0mval1\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m==\u001b[0m\u001b[0mval1\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msum\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0matlas2\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0matlas2\u001b[0m\u001b[0;34m==\u001b[0m\u001b[0mval2\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m==\u001b[0m\u001b[0mval2\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m     39\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     40\u001b[0m             \u001b[0mDice\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mi\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mj\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mfloat\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdice\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;31mKeyboardInterrupt\u001b[0m: "
     ]
    }
   ],
   "source": [
    "def main():\n",
    "    # All inputs listed below are required\n",
    "    parser = ArgumentParser(\n",
    "        description=\"Script to take already MNI-aligned atlas images and generate json file information.\"\n",
    "    )\n",
    "    parser.add_argument(\n",
    "        \"input_dir\",\n",
    "        help=\"Input directory\",\n",
    "        action=\"store\",\n",
    "    )\n",
    "    parser.add_argument(\n",
    "        \"output_dir\",\n",
    "        help=\"\"\"Path to directory you wish to store output\n",
    "        heatmap.\"\"\",\n",
    "        action=\"store\",\n",
    "    )\n",
    "    parser.add_argument(\n",
    "        \"atlases\",\n",
    "        help=\"\"\"List of names of the mri parcellations\n",
    "        file you intend to process. Each atlas will be compared\n",
    "        to eachother, so [a,b,c] will generate axb, axc, bxc.\"\"\",\n",
    "        nargs=\"+\",\n",
    "    )\n",
    "    \n",
    "\n",
    "    # and ... begin!\n",
    "    print(\"\\nBeginning Dice ...\")\n",
    "\n",
    "    # ---------------- Parse CLI arguments ---------------- #\n",
    "    result = parser.parse_args()\n",
    "    input_dir = result.input_dir\n",
    "    atlases = result.atlases\n",
    "    output_dir = result.output_dir\n",
    "    \n",
    "    # Print the inputs for early issue detection\n",
    "    print(f\"input directory = {input_dir}\")\n",
    "    print(f\"output directory = {output_dir}\")\n",
    "    print(f\"atlases to be analyzed{atlases}\")\n",
    "\n",
    "    # Creation of output_dir if it doesn't exit\n",
    "    if not os.path.isdir(output_dir):\n",
    "        print(f\"Making output directory: {output_dir}\")\n",
    "        os.makedirs(f\"{output_dir}\")\n",
    "\n",
    "    # Itterate through every combination of the atlases provided (except duplicates)\n",
    "    for i in range(len(atlases)):\n",
    "        for j in range(len(atlases)):\n",
    "            if j > i:\n",
    "                Dice_matrix, ylabels, xlabels = dice_roi(input_dir,output_dir,atlases[i],atlases[j])\n",
    "\n",
    "if __name__ == \"__main__\":\n",
    "    main()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Outputs:\n",
    "After running this script to completion, for every potential combination of atlases you should have the following in your output directory:\n",
    "1. A file named Dice\\_{atlas1}\\_&\\_{atlas2}\\_res-{vox}x{vox}x{vox}.png, containing a heatmap of the dice coefficients for each ROI.\n",
    "2. A file named Dice\\_{atlas1}\\_&\\_{atlas2}\\_res-{vox}x{vox}x{vox}.csv, containing the dice coefficient matrix information for the acccompanying png file.\n",
    "\n",
    "## Common Errors:\n",
    "- Issues may arise if atlases being compared have different voxel sizes, as the overlap measured by the dice coefficient may not be accurate\n",
    "- If the atlases you are using do not contain 'space-MNI152NLin6_res-' or end in either '.nii' or '.nii.gz', issues will arise in the naming structure of the output files. Either rename your atlases or edit the first 5 lines of code of the third code cell."
   ]
  }
 ],
 "metadata": {
  "file_extension": ".py",
  "kernelspec": {
   "display_name": "Python 3.7.3 64-bit",
   "language": "python",
   "name": "python37364bit7aebd514ba8143f191d4fea51945eb11"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  },
  "mimetype": "text/x-python",
  "name": "python",
  "npconvert_exporter": "python",
  "pygments_lexer": "ipython3",
  "version": 3
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
